package 字符串算法;

import java.util.Scanner;

public class 括号匹配深度 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int cnt = 0 ;int max = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='('){
                cnt++;
            }else {
                cnt--;
            }
          max = Math.max(cnt,max);
        }
        scanner.close();
        System.out.println(max);

    }
}
